<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录 - 灵犀智苑</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
        }

        :root {
            --primary: #4361ee;
            --primary-light: #5e72e4;
            --secondary: #4cc9f0;
            --accent: #e67e22;
            --light: #ecf0f1;
            --dark: #34495e;
            --darker: #2c3e50;
            --text: #2c3e50;
            --text-light: #7f8c8d;
            --glass: rgba(255, 255, 255, 0.2);
            --border: rgba(255, 255, 255, 0.3);
            --shadow: 0 8px 32px rgba(31, 38, 135, 0.15);
            --transition: all 0.3s ease;
        }

        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #e4e7eb 100%);
            color: var(--text);
            min-height: 100vh;
            overflow-x: hidden;
            display: flex;
            flex-direction: column;
        }

        .background-blur {
            position: fixed;
            top: -50px;
            left: -50px;
            right: -50px;
            bottom: -50px;
            background: url('');
            filter: blur(40px);
            z-index: -1;
        }

        /* 玻璃拟态效果 */
        .glass {
            background: var(--glass);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--border);
            box-shadow: var(--shadow);
            border-radius: 20px;
            overflow: hidden;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 0 2rem;
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        /* 导航栏 */
        header {
            padding: 1rem 0;
        }

        .navbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 1rem 2rem;
            position: relative;
            z-index: 100;
        }

        .logo {
            display: flex;
            align-items: center;
            font-size: 1.8rem;
            font-weight: 700;
            background: linear-gradient(90deg, var(--primary), var(--accent));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .logo-icon {
            margin-right: 10px;
            animation: float 3s ease-in-out infinite;
        }

        .nav-links {
            list-style: none;
            display: flex;
            gap: 2rem;
        }

        .nav-links a {
            color: var(--darker);
            text-decoration: none;
            font-weight: 500;
            padding: 8px 0;
            position: relative;
            transition: var(--transition);
        }

        .nav-links a:after {
            content: '';
            position: absolute;
            width: 0;
            height: 2px;
            bottom: 0;
            left: 0;
            background: var(--primary);
            transition: var(--transition);
        }

        .nav-links a:hover:after,
        .nav-links a.active:after {
            width: 100%;
        }

        .nav-links a.active {
            color: var(--primary);
        }

        .cta-buttons {
            display: flex;
            gap: 1rem;
        }

        .btn {
            padding: 0.7rem 1.5rem;
            border-radius: 12px;
            border: none;
            cursor: pointer;
            font-weight: 500;
            transition: var(--transition);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 1rem;
        }

        .btn-login {
            background: transparent;
            color: var(--darker);
            border: 1px solid var(--border);
        }

        .btn-login:hover {
            background: rgba(255, 255, 255, 0.2);
            transform: translateY(-2px);
        }

        .btn-signup {
            background: linear-gradient(90deg, var(--primary), var(--secondary));
            color: white;
            box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
        }

        .btn-signup:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 20px rgba(67, 97, 238, 0.4);
        }

        /* 登录表单 */
        .login-container {
            width: 100%;
            max-width: 500px;
            padding: 3rem;
            margin: 2rem auto;
        }

        .login-header {
            text-align: center;
            margin-bottom: 2.5rem;
        }

        .login-header h1 {
            font-size: 2.5rem;
            margin-bottom: 1rem;
            background: linear-gradient(90deg, var(--primary), var(--accent));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .login-header p {
            font-size: 1.1rem;
            color: var(--text-light);
        }

        .login-form {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
        }

        .form-group {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }

        .form-group label {
            font-weight: 500;
            color: var(--darker);
        }

        .glass-input {
            background: rgba(255, 255, 255, 0.15);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 14px 20px;
            font-size: 16px;
            color: var(--text);
            transition: var(--transition);
            width: 100%;
        }

        .glass-input:focus {
            outline: none;
            background: rgba(255, 255, 255, 0.25);
            box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.3);
        }

        .remember-forgot {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 0.9rem;
            color: #4a5568;
        }

        .remember-forgot a {
            color: var(--primary);
            text-decoration: none;
        }

        .remember-forgot a:hover {
            text-decoration: underline;
        }

        .btn-login-form {
            background: linear-gradient(90deg, var(--primary), var(--accent));
            color: white;
            padding: 1rem;
            border-radius: 15px;
            font-weight: 600;
            font-size: 1.1rem;
            border: none;
            cursor: pointer;
            box-shadow: 0 5px 20px rgba(114, 9, 183, 0.3);
            transition: var(--transition);
            margin-top: 1rem;
        }

        .btn-login-form:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 25px rgba(114, 9, 183, 0.4);
        }

        .social-login {
            text-align: center;
            margin-top: 2rem;
        }

        .divider {
            display: flex;
            align-items: center;
            text-align: center;
            color: #718096;
            margin: 1.5rem 0;
        }

        .divider::before,
        .divider::after {
            content: "";
            flex: 1;
            border-bottom: 1px solid #e2e8f0;
        }

        .divider::before {
            margin-right: 1rem;
        }

        .divider::after {
            margin-left: 1rem;
        }

        .social-icons {
            display: flex;
            justify-content: center;
            gap: 1.5rem;
        }

        .social-btn {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background: transparent;
            border: 1px solid var(--border);
            font-size: 1.2rem;
            cursor: pointer;
            transition: var(--transition);
        }

        .social-btn:hover {
            background: rgba(255, 255, 255, 0.2);
            transform: translateY(-3px);
        }

        .signup-link {
            text-align: center;
            color: #4a5568;
            margin-top: 1.5rem;
        }

        .signup-link a {
            color: var(--primary);
            font-weight: 500;
            text-decoration: none;
        }

        .signup-link a:hover {
            text-decoration: underline;
        }

        .back-to-home {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            color: var(--primary);
            text-decoration: none;
            margin-top: 1.5rem;
            font-weight: 500;
        }

        .back-to-home:hover {
            text-decoration: underline;
        }

        /* 动画 */
        @keyframes float {
            0% {
                transform: translateY(0px);
            }
            50% {
                transform: translateY(-15px);
            }
            100% {
                transform: translateY(0px);
            }
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .navbar {
                flex-direction: column;
                gap: 1.5rem;
            }
            
            .nav-links {
                flex-wrap: wrap;
                justify-content: center;
            }
            
            .login-container {
                padding: 2rem 1.5rem;
            }
        }
    </style>
</head>
<body>
    <div class="background-blur"></div>
    
    <header>
        <nav class="navbar glass">
            <div class="logo">
                <span class="logo-icon">✨</span>
                <span>灵犀智苑</span>
            </div>
            <ul class="nav-links">
                <li><a href="index.html">首页</a></li>
                <li><a href="design.html">AI设计</a></li>
                <li><a href="mall.html">家具商城</a></li>
                <li><a href="idea.html">灵感库</a></li>
                <li><a href="partner.html">商家合作</a></li>
            </ul>
            <div class="cta-buttons">
                <a href="login.html" class="btn btn-login glass active">登录</a>
                <a href="register.html" class="btn btn-signup">免费注册</a>
            </div>
        </nav>
    </header>

    <main class="container">
        <div class="login-container glass">
            <div class="login-header">
                <h1>欢迎回来</h1>
                <p>请登录您的账户继续使用灵犀智苑</p>
            </div>
            
            <form class="login-form">
                <div class="form-group">
                    <label for="name">用户名/手机号</label>
                    <input type="text" id="name" class="glass-input" placeholder="请输入用户名或手机号">
                </div>
                
                <div class="form-group">
                    <label for="password">密码</label>
                    <input type="password" id="password" class="glass-input" placeholder="请输入密码">
                </div>
                
                <div class="remember-forgot">
                    <label>
                        <input type="checkbox"> 记住我
                    </label>
                    <a href="#">忘记密码？</a>
                </div>
                
                <button type="submit" class="btn-login-form">登录</button>
            </form>
            

            
            <div class="signup-link">
                新用户？<a href="register.html">立即注册</a>
            </div>
            
            <a href="index.html" class="back-to-home">
                <i class="fas fa-arrow-left"></i> 返回首页
            </a>
        </div>
    </main>

    <script>
    document.addEventListener('DOMContentLoaded', () => {
        // 设置API基础URL（与注册页面保持一致）
        const API_BASE_URL = 'http://localhost:8088/another/'; // 开发环境
        // const API_BASE_URL = 'https://api.lingxizhiyuan.com'; // 生产环境
        
        // 表单提交处理
        const loginForm = document.querySelector('.login-form');
        
        loginForm.addEventListener('submit', (e) => {
            e.preventDefault();
            
            const name = document.getElementById('name').value;
            const password = document.getElementById('password').value;
            
            // 这里可以添加表单验证逻辑
            if (!name || !password) {
                alert('请输入用户名和密码');
                return;
            }
            
            // 模拟登录过程
            const loginBtn = document.querySelector('.btn-login-form');
            const originalText = loginBtn.innerHTML;
            
            loginBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> 登录中...';
            loginBtn.disabled = true;
            
            // 发送登录请求
            fetch(`${API_BASE_URL}/user/user/login`, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({
                    name: name,
                    password: password
                })
            })
            .then(response => response.json())
            .then(data => {
                if (data.code === 1) {
                    // 登录成功，保存token到localStorage
                    localStorage.setItem('authToken', data.data.token);
                    localStorage.setItem('userId', data.data.id);
                    
                    // 跳转到首页
                    window.location.href = 'index.html';
                } else {
                    alert('登录失败: ' + data.msg);
                    loginBtn.innerHTML = originalText;
                    loginBtn.disabled = false;
                }
            })
            .catch(error => {
                console.error('登录请求错误:', error);
                alert('登录请求失败，请稍后重试');
                loginBtn.innerHTML = originalText;
                loginBtn.disabled = false;
            });
        });
    });
</script>
</body>
</html>